local gezhi = fk.CreateSkill {
  name = "lingling__gezhi",
}

Fk:loadTranslationTable{
  ["lingling__gezhi"] = "革制",
  [":lingling__gezhi"] = "准备阶段，你可以令所有角色各移动场上一张装备牌（你最后移动）。",

  ["#lingling__gezhi-invoke"] = "革制：你可以令所有角色各移动场上一张装备牌",
  ["#lingling__gezhi-move"] = "革制：请移动场上一张装备牌",
}

gezhi:addEffect(fk.EventPhaseStart, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(gezhi.name) and player.phase == Player.Start and
      #player.room:canMoveCardInBoard("e") > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askToSkillInvoke(player, {
      skill_name = gezhi.name,
      prompt = "#lingling__gezhi-invoke",
    }) then
      event:setCostData(self, {tos = room:getAlivePlayers()})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tos = room:getOtherPlayers(player)
    table.insert(tos, player)
    for _, p in ipairs(tos) do
      if #room:canMoveCardInBoard("e") == 0 then return end
      if not p.dead then
        local targets = room:askToChooseToMoveCardInBoard(p, {
          flag = "e",
          prompt = "#lingling__gezhi-move",
          skill_name = gezhi.name,
          cancelable = false,
        })
        room:askToMoveCardInBoard(p, {
          target_one = targets[1],
          target_two = targets[2],
          skill_name = gezhi.name,
          flag = "e",
        })
      end
    end
  end,
})

return gezhi
